#ifndef WARNINGLOGMODEL_H
#define WARNINGLOGMODEL_H

#include <QAbstractListModel>
#include <QObject>
#include "databasemanager.h"
#define WARNING_LOG(strlog)  WarningLogModel::getInstance()->addData(strlog);

class WarningLogModel : public QAbstractListModel
{
    Q_OBJECT
public:
    enum OperateLogRoles {
        TimeRole= Qt::UserRole + 1,
        RobotRole,
        LogRole
    };
    explicit WarningLogModel(QObject *parent = nullptr);
    static WarningLogModel * getInstance();
    void initData();
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
    QHash<int, QByteArray> roleNames() const override;
    void addData(QString strlog);
    void deleteDatas();
private:
    static WarningLogModel *m_pInstance;
    QVector<WarningInfo> m_data;
};

#endif // WARNINGLOGMODEL_H
